package org.liaohailong.victorlibrary.ui

import android.content.Context
import android.content.Intent
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_audio_interact.*
import org.liaohailong.library.widget.interact.IInteractView
import org.liaohailong.library.widget.interact.Message
import org.liaohailong.victorlibrary.R
import org.liaohailong.victorlibrary.base.BaseActivity

/**
 * Author: liaohailong
 * Date: 2019/3/12
 * Time: 5:31 PM
 * Description: 音频播放
 **/
class AudioInteractActivity : BaseActivity() {
    companion object {
        fun show(context: Context) {
            val intent = Intent(context, AudioInteractActivity::class.java)
            context.startActivity(intent)
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_audio_interact)
//        val message = Message("https://dev-cdn.api.wanzi.cn/debug/test/3.mp4")
        val message = Message("",
                "",
                "https://dev-cdn.api.wanzi.cn/videos/video-custom-adv/2019-03-07/users/311/2c0793584325af1ff3f75cd6676436f9/2c0793584325af1ff3f75cd6676436f9_sd.mp4",
                Message.Type.AUDIO)
        audio_view.play(message, object : IInteractView.InteractViewCallback {
            override fun onInteractViewPrepared(message: Message) {
                //do nothing...
            }

            override fun onInteractPlayComplete(message: Message) {
                //do nothing...
            }
        })
    }

    override fun onDestroy() {
        super.onDestroy()
        audio_view.release()
    }
}